package cao.oschina.activity;

import android.os.Bundle;
import android.view.View;

import cao.oschina.R;
import cao.oschina.app.AppContext;
import cao.oschina.widget.ToolBarView;
import lib.toolbar.activity.SideBarToolBarActivity;

/**
 * 主界面Activity
 * <p/>
 * Created by Haidy on 15/3/13.
 */
public class MainActivity extends SideBarToolBarActivity {

    public AppContext app;
    private ToolBarView toolBarView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        app = (AppContext) getApplication();
        toolBarView = new ToolBarView(getBaseContext());
        setToolBar(toolBarView);
        toolBarView.setBackgroundColor(getResources().getColor(R.color.app_green));
        setTitle(R.string.app_name);
        toolBarView.getNavigationView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isOpen()) {
                    open();
                }
            }
        });
    }

    @Override
    public void setTitle(CharSequence title) {
        toolBarView.setTitle(title);
    }

    /**
     * 打开新的activity动画
     */
    public void activityPushAnim() {
        overridePendingTransition(R.anim.activity_anim_push_in, R.anim.activity_anim_push_out);
    }

}
